{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from bqplot import (\n",
    "    Figure, Map, Mercator, Orthographic, ColorScale, ColorAxis,\n",
    "    AlbersUSA, topo_load, Tooltip\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Basic Map ##"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sc_geo = Mercator()\n",
    "map_mark = Map(scales={'projection': sc_geo})\n",
    "Figure(marks=[map_mark], title='Basic Map Example')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Advanced Map and Projection ##"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sc_geo = Orthographic(scale_factor=375, center=[0, 25], rotate=(-50, 0))\n",
    "map_mark = Map(map_data=topo_load('map_data/WorldMap.json'), scales={'projection': sc_geo}, \n",
    "        colors={682: 'Green', 356: 'Red', 643: '#0000ff', 'default_color': 'DarkOrange'})\n",
    "Figure(marks=[map_mark], fig_color='deepskyblue', title='Advanced Map Example')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sc_geo.scale = 350"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Choropleth ##"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sc_geo = Mercator()\n",
    "sc_c1 = ColorScale(scheme='YlOrRd')\n",
    "\n",
    "map_styles = {'color': {643: 105., 4: 21., 398: 23., 156: 42., 124:78., 76: 98.},\n",
    "              'scales': {'projection': sc_geo, 'color': sc_c1}, 'colors': {'default_color': 'Grey'}}\n",
    "\n",
    "axis = ColorAxis(scale=sc_c1)\n",
    "\n",
    "chloro_map = Map(map_data=topo_load('map_data/WorldMap.json'), **map_styles)\n",
    "Figure(marks=[chloro_map], axes=[axis],title='Choropleth Example')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## USA State Map ##"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sc_geo = AlbersUSA()\n",
    "states_map = Map(map_data=topo_load('map_data/USStatesMap.json'), scales={'projection': sc_geo})\n",
    "Figure(marks=[states_map], title='US States Map Example')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Europe Country Map"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "sc_geo = Mercator(scale_factor=450)\n",
    "euro_map = Map(map_data=topo_load('map_data/EuropeMap.json'), \n",
    "            scales={'projection': sc_geo})\n",
    "Figure(marks=[euro_map], title='Europe States Map Example')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Interactions ##"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def_tt = Tooltip(fields=['id', 'name'])\n",
    "map_mark = Map(scales={'projection': Mercator()}, tooltip=def_tt)\n",
    "map_mark.interactions = {'click': 'select', 'hover': 'tooltip'}\n",
    "Figure(marks=[map_mark], title='Interactions Example')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
